/*
 * Copyright 2012-2019 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.boot.context.properties.bind;

import java.lang.reflect.Constructor;

/**
 * 用于确定绑定时使用的特定构造函数的策略接口。
 *
 * @author Madhura Bhave
 * @since 2.2.1
 */
@FunctionalInterface
public interface BindConstructorProvider {

	/**
	 * 默认的 {@link BindConstructorProvider} 实现，
	 * 仅在绑定目标有且仅有一个构造函数且绑定目标没有已有值时返回该构造函数。
	 */
	BindConstructorProvider DEFAULT = new DefaultBindConstructorProvider();

	/**
	 * 返回用于给定绑定目标的绑定构造函数，如果不支持构造函数绑定则返回 {@code null}。
	 * @param bindable 要检查的绑定目标
	 * @param isNestedConstructorBinding 指示该绑定是否嵌套在构造函数绑定中
	 * @return 绑定构造函数或 {@code null}
	 */
	Constructor<?> getBindConstructor(Bindable<?> bindable, boolean isNestedConstructorBinding);

}
